package edu.Ding.A0408;

import java.util.Arrays;
import java.util.Scanner;

//用户在控制台输入三个单词，按照首字母将用户输入的单词进行排序
public class Demo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入三个单词，中间用空格隔开");
        String str1 = scanner.next();
        String str2 = scanner.next();
        String str3 = scanner.next();
        String artArr[] = new String[] { str1, str2, str3 };
        for (int i = 0; i < artArr.length - 1; i++) {
            for (int j = i + 1; j < artArr.length; j++) {
                if (artArr[i].charAt(0) > artArr[j].charAt(0)) {
                    String temp = artArr[i];
                    artArr[i] = artArr[j];
                    artArr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(artArr));
        scanner.close();
    }
}